module dgl.Vector4;

import str = tango.text.convert.Float;
import dgl.Vector2;
import dgl.Vector3;

struct Vector4
{
	private float[4] m_vector;

	public float x()
	{
		return m_vector[0];
	}

	public float y()
	{
		return m_vector[1];
	}

	public float z()
	{
		return m_vector[2];
	}

	public float w()
	{
		return m_vector[3];
	}

	public void x( float x )
	{
		m_vector[0] = x;
	}

	public void y( float y )
	{
		m_vector[1] = y;
	}

	public void z( float z )
	{
		m_vector[2] = z;
	}

	public void w( float w )
	{
		m_vector[3] = w;
	}

	public float * ptr()
	{
		return m_vector.ptr;
	}

	public static Vector4 opCall( float x, float y, float z, float w )
	{
		Vector4 ret;
		ret.x = x;
		ret.y = y;
		ret.z = z;
		ret.w = w;
		return ret;
	}

	public static Vector4 opCall( float value )
	{
		Vector4 ret;
		ret.x = value;
		ret.y = value;
		ret.z = value;
		ret.w = value;
		return ret;
	}

	public static Vector4 opCall( Vector2 value, float z, float w )
	{
		Vector4 ret;
		ret.x = value.x;
		ret.y = value.y;
		ret.z = z;
		ret.w = w;
		return ret;
	}

	public static Vector4 opCall( Vector3 value, float w )
	{
		Vector4 ret;
		ret.x = value.x;
		ret.y = value.y;
		ret.z = value.z;
		ret.w = w;
		return ret;
	}

	public static Vector4 one()
	{
		return Vector4( 1, 1, 1, 1 );
	}

	public static Vector4 zero()
	{
		return Vector4( 0, 0, 0, 0 );
	}
	
	public Vector4 opDiv( float value )
	{
		Vector4 vector;
		vector.x = this.x / value;
		vector.y = this.y / value;
		vector.z = this.z / value;
		vector.w = this.w / value;
		return vector;
	}

	public char[] toString()
	{
		char[] ret = "";
		ret ~= "{ " ~ str.toString( x );
		ret ~= ", " ~ str.toString( y );
		ret ~= ", " ~ str.toString( z );
		ret ~= ", " ~ str.toString( w );
		ret ~= " }";
		return ret;
	}
}